import openpyxl
import hashlib
import json

wb = openpyxl.load_workbook("./名单.xlsx")
# print(wb.sheetnames)

data = {}
s = set()
for sheet in wb.sheetnames:
    flag_first_line = 1
    data[sheet] = {}
    worksheet = wb[sheet]
    keys = None
    data[sheet] = []
    # print(worksheet.rows)
    for row in worksheet.values:
        if flag_first_line == 1:
            flag_first_line = 0
            keys = list(row)
            # print(keys)
        else:
            di = dict(zip(keys,row))
            data[sheet].append(di)
            # print(di['身份证号'])
            tt = hashlib.md5((di['身份证号']+sheet).encode()).hexdigest()[-7:]
            data[sheet][-1]["uuid"] = tt
            # # print(tt)
            # if tt not in s:
                # s.add(tt)
            # else:
                # print(tt)
                # print(sheet)
                # print(di)
            # break

print(json.dumps(data,ensure_ascii=False))
